import React, { useState } from 'react';
import { Form, Input, InputNumber } from 'antd';
import an58 from '@mmstudio/an000058';
import EditButton from '../../../components/editbutton';
import { Message as M1, Result as R1 } from '../../api/professional/profession/edit.api';
import api from '../../../atoms/api';



export default function Edit({ data }: {
	data: M1;

}) {
	const [d, setd] = useState(data);
	return <>
		<EditButton dlgtitle='专业管理' onSave={async () => {
			if (!d
				|| !d.major_id
				|| !d.objectives
				|| !d.professionalprofile
				|| !d.majorname
			) {
				return '缺少必要的参数';
			}
			const res = await an58<R1, M1>(api['/api/professional/profession/edit'], 'post', d);
			if (res.ok === true) {
				return true;
			}
			return res.message;
		}}>
			<Form.Item required label="专业名称">
				<Input placeholder='请输入专业名称' value={d.majorname} onChange={(e) => {
					setd({
						...d,
						majorname: e.target.value
					});
				}} />
			</Form.Item>
			<Form.Item required label="人才培养目标">
				<textarea className='da' placeholder='请输入培养目标' onChange={(e) => {
					setd({
						...d,
						objectives: e.target.value
					});
				}} >{d.objectives}</textarea>
			</Form.Item>
			<Form.Item required label="专业简介">
				<textarea className='ta' placeholder='请输入简介' onChange={(e) => {
					setd({
						...d,
						professionalprofile: e.target.value
					});
				}} >{d.professionalprofile}</textarea>
			</Form.Item>
		</EditButton>
		<style jsx>{`
		.ta{
width:100%;
height:10rem;
}
.da{
width:100%;
height:10rem;
}
		`}</style>
	</>;
}
